#include <helper_image.h>
#include <stdlib.h>
#include "Filters/FILTERS_test.h"
#include "CCL/CCL_test.h"
#include "functions.h"

int main(int argc, char** argv){
	int deviceCount = 0;
	int deviceChoosen = 0;
	cudaDeviceProp deviceProp;
	bool b=true;
	unsigned char* tmpImg = NULL;
	uchar4* img = NULL;
	unsigned int width, height;
	int dims[6]={0};
	int pixelsPerThread = 8;
	int umbral = 125;
	int op=0;
	if(argc<=1){
		return 0;
	}
	else{
		//INFO SOBRE LAS PLACAS EXISTENTES
		//COMENTADO PARA USAR EL SCRIPT.PY
		/*deviceCount = chooseCudaDevice();
		printf("Elija el dispositivo CUDA que desea utilizar: ");
		scanf("%d", &deviceChoosen);*/
		if(deviceChoosen >= 0 && deviceChoosen <= deviceCount){
			cudaSetDevice(deviceChoosen);
			cudaGetDeviceProperties(&deviceProp,deviceChoosen);

			//CARGO LA IMAGEN EN DISCO
			b=sdkLoadPPM4(argv[1], &tmpImg, &width, &height);
			if(!b){
				cout<< "no se pudo cargar la imagen" << endl;
				exit(EXIT_FAILURE);
			}
			printf("***************imagen %s\n",argv[1]);
			img = reinterpret_cast<uchar4 *>(tmpImg);
			if(atoi(argv[2])==0)
				compareCCL(img, width, height, deviceProp, pixelsPerThread, umbral);
			else
				compararFiltro(img,width,height, dims, pixelsPerThread, atoi(argv[2]));
			free(img);
			img=NULL;
		}
	}
	cudaDeviceReset();
}

